package com.orange.common.validation.annotation.impl;


import com.orange.common.validation.annotation.StrictID;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import java.util.regex.Pattern;

/**
 * 业务ID校验器
 *
 * @Author YWF
 * @Date 2025/5/8 17:20
 */
public class StrictIDValidator implements ConstraintValidator<StrictID,String> {

    private static final Pattern ID_PATTERN =
            Pattern.compile("^DCS\\d{8}$");
    @Override
    public boolean isValid(String value, ConstraintValidatorContext context) {
        if (value == null){
            return true;
        }
        return ID_PATTERN.matcher(value).matches();
    }
}
